//
//  YYUserAccount.swift
//  SinaWeibo
//
//  Created by Apple on 16/5/9.
//  Copyright © 2016年 devshaw. All rights reserved.
//

import UIKit

class YYUserAccount: NSObject {

    var access_token: String?

    var expires_in: NSTimeInterval = 0

    var uid: String?

    var screen_name: String?

    var profile_image_url: String?

    init(dic: [String: AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dic)
    }


    override func setValue(value: AnyObject?, forUndefinedKey key: String) {    }




     // MARK: - 归档和解档
    //归档---- 将对象保存成二进制保存进沙盒里

    func encodeWithCoder(aCoder: NSCoder){
        aCoder.encodeObject(access_token,forKey: "access_token")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        aCoder.encodeObject(profile_image_url, forKey: "profile_image_url")
    }

    required init?(code aDecoder: NSCoder) {
        self.access_token = aDecoder.decodeObjectForKey("access_token") as? String
        self.expires_in = (aDecoder.decodeObjectForKey("expires_in") as? NSTimeInterval)!

    }
}
